<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@ taglib uri="/WEB-INF/tld/extend.tld" prefix="extend"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>乐盈培训网 - 查询讲师信息</title>
		<link href="<extend:contextPath name="contextPath"/>/css/style.css" rel="stylesheet" type="text/css" />
		<script language="JavaScript" src="<extend:contextPath name="contextPath"/>/scripts/common.js"></script>
	</head>	

		
	<body>
	<div style="position:absolute; height:100%; width:1045px;">
		<jsp:include page="../header.jsp"></jsp:include>
			<table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;">
					<tr>
						<td height="25px">
							您现在的位置：<a href="<extend:contextPath name="contextPath"/>" class="normal_link">首页</a> >> 
							<a href="<extend:contextPath name="contextPath"/>/admin/goToAdmin.do" class="normal_link">admin</a> >> 查找教师
						</td>
					</tr>
			</table>
		<html:form action="/searchTeacherProcess.do?method=searchTeacherProcess"> 
			<table style="margin-top:15px; font-size:14px" cellpadding="0" cellspacing="0">
				<tr>	
					<td height=30px>教师名称：</td>
					<td><html:text property="teacherName" /></td>
				</tr>
				 <tr>	
					<td height=30px>教师描述：</td>
					<td><html:text property="teacherDesc" /></td>
				</tr>
				<tr>	
					<td height=30px>教学专业：</td>
					<td><html:text property="teachMajor" /></td>
				</tr>				
				<tr>
					<td><html:submit>提交</html:submit></td>
				</tr>												
			</table>
		</html:form>

	<c:choose>
		<c:when test='${empty teacherList}'>
			<c:if test='${teacherList != null}'>
				没有找到符合记录。
			</c:if>
		</c:when>
		<c:otherwise>
			<html:form action="/deleteTeacher.do?method=deleteTeacher" onsubmit="return confirm('确定要删除该条记录吗？相关课程信息也将被删除');">
				<table style="margin-left:20px; margin-top:15px; font-size:14px" width="740px" cellpadding="0" cellspacing="0">
					<tr>
						<td align="left" width="10px"><input type="checkbox" name="masterCheckbox" onclick="toggleCheckboxes(form.deleteSelection, this.checked)"></td>
						<td align="left" width="5px">No.</td>
						<td align="left" width="100px">教师名称</td>
						<td align="left" width="100px">教学专业</td>
						<td align="left" width="500">教师描述</td>
						<td width="10px">&nbsp;</td>
						<td width="10px">&nbsp;</td>
					</tr>
					
					<c:forEach var="teacher" items="${teacherList}" varStatus="status">
						<tr>
							<td align="left" width="10px" height="30px">
								<html:multibox property="deleteSelection" 
									onclick="toggleMasterCheckbox(masterCheckbox, this.checked, deleteSelection)">
									<c:out value="${teacher.teacherId}" />|<c:out value='${teacher.version}' />
								</html:multibox>
							</td>
							<td align="left" width="10px"><c:out value="${status.index + 1}" /></td>
							<td><c:out value="${teacher.teacherName}" /></td>
							<td><c:out value="${teacher.teachMajor}" /></td>
							<td><c:out value="${teacher.teacherDesc}" /></td>
							<td id="sc_edit" align="center"><a class="href_edit" title="编辑" href="#" 
										onclick="javascript:viewEditTeacher('<c:out value='${teacher.teacherId}' />')">&nbsp;</a>
							</td>							
							<td id="sc_delete" align="center"><a class="href_delete" title="删除" href="#" 
										onclick="javascript:deleteTeacher('<c:out value='${teacher.teacherId}' />','<c:out value='${teacher.version}' />')">&nbsp;</a>
							</td>
						</tr>							
					</c:forEach>
					
					<tr>
						<td colspan="10">
							<extend:paginationNav currentPage="${paginationSortOrderData.currentPage}" pageSize="${paginationSortOrderData.pageSize}" totalCount="${totalCount}"/>						
						</td> 
					</tr>
					
					<tr>
						<td><html:submit>删除</html:submit></td>
					</tr>

					<script>
						function resubmit(i)
						{
							document.forms[1].action="<extend:contextPath name="contextPath"/>/admin/searchTeacherProcess.do?method=searchTeacherProcess&page=" + i;
							document.forms[1].method="post";
							document.forms[1].submit();	
						}
					</script>										
				</table>
				<html:hidden property="teacherName"/>
				<html:hidden property="teacherDesc"/>
				<html:hidden property="teachMajor"/>
			</html:form>
		</c:otherwise>
	</c:choose>
	
	<script>
		function deleteTeacher(id,version)
		{
			if(confirm("确定要删除记录吗？相关课程信息也将被删除"))
			{
			document.forms[1].action = "<extend:contextPath name="contextPath"/>/admin/deleteTeacher.do?method=deleteTeacher&teacherId=" + id+"&version=" + version;
			document.forms[1].method = "post";
			document.forms[1].submit();
		}
		}

		function viewEditTeacher(id)
		{
			window.location = "<extend:contextPath name="contextPath"/>/admin/viewEditTeacher.do?method=viewEditTeacher&teacherId=" + id;
		}
	</script>	
	</div>
	
	</body>
</html>